const curry = (fn) =>
(judge = (...args) =>
    args.length === fn.length
        ? fn(...args)
        : (...arg) => judge(...args, ...arg));


const add = (a, b, c) => a + b + c;
const curryAdd = curry(add);
console.log(curryAdd(1)(2)(3)); // 6
console.log(curryAdd(1, 2)(3)); // 6
console.log(curryAdd(1)(2, 3)); // 6